package com.qin.malldiscount.service.impl;

import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.qin.malldiscount.domain.CmsSubject;
import com.qin.malldiscount.service.CmsSubjectService;
import com.qin.malldiscount.mapper.CmsSubjectMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
* @author 覃剑
* @description 针对表【cms_subject(专题表)】的数据库操作Service实现
* @createDate 2022-11-23 16:22:33
*/
@Service
public class CmsSubjectServiceImpl extends ServiceImpl<CmsSubjectMapper, CmsSubject>
    implements CmsSubjectService{
    
    @Autowired
    private CmsSubjectMapper subjectMapper;


    /**
     * 查询所有专题
     */
    @Override
    public List<CmsSubject> listAll() {
        List<CmsSubject> subjectList = subjectMapper.selectList(null);
        return subjectList;
    }

    /**
     * 分页查询专题
     */
    @Override
    public Page<CmsSubject> getList(String keyword, Integer pageNum, Integer pageSize) {
        Page<CmsSubject> subjectPage = new Page<>(pageNum, pageSize);
        QueryWrapper<CmsSubject> wrapper = new QueryWrapper<>();
        if (StrUtil.isNotEmpty(keyword)){
            wrapper.like("title","%"+keyword+"%");
        }
        Page<CmsSubject> page = subjectMapper.selectPage(subjectPage, wrapper);
        return page;
    }
}




